/**
 * 文件名:TbuserServiceImpl.java
 * 包名:com.wx.demo.webc.service.impl
 * 创建时间:2017年2月17日下午2:03:53
 * <p>Copyright ®医界互联 TUS 平台版权所有。</p>
 *
 */

package com.wx.demo.wcd.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wx.demo.wcd.domain.po.TbuserPO;
import com.wx.demo.wcd.domain.qo.TbuserQO;
import com.wx.demo.wcd.infrastructure.dao.TbuserDao;
import com.wx.demo.wcd.service.TbuserService;
import com.yjhl.framework.dao.query.Page;

/**
 * 类名:TbuserServiceImpl <br/>
 * 创建时间: 2017年2月17日 下午2:03:53 <br/>
 * 
 * @author 王笑 Email:wangxiao@yijiehulian.com.
 * @version
 * @since JDK 1.8
 * @see
 */
@Service("tbuserService")
public class TbuserServiceImpl implements TbuserService {
	private Logger logger = Logger.getLogger(getClass());

	@Autowired
	private TbuserDao userDao;

	@Override
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public int insert(TbuserPO user) throws Exception {

		logger.debug("insert user content ===>" + user.inputDescription());

		int rows = userDao.insert(user);

		logger.debug("insert user columns ===> " + rows);

		return rows;
	}

	@Override
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public int insertBatch(List<TbuserPO> lu) throws Exception {

		logger.debug("insertBatch List<TbuserPO> lp content ===>"
				+ lu.toString());

		int rows = userDao.insertBatch(lu);

		logger.debug("insertBatch columns ===> " + rows);

		return rows;
	}

	@Override
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public int edit(TbuserPO entityPo, TbuserQO entityQo) throws Exception {

		logger.debug("edit entityPo content ===>" + entityPo.inputDescription());
		logger.debug("edit entityQo content ===>" + entityQo.inputDescription());

		int rows = userDao.updateSelective(entityPo, entityQo);

		logger.debug("edit columns ===> " + rows);

		return rows;
	}

	@Override
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public int delete(String user_id) throws Exception {

		logger.debug("delete user_id content ===>" + user_id);

		int rows = userDao.deleteByPk(user_id);

		logger.debug("delete columns ===>" + rows);

		return rows;
	}

	@Override
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public int deleteBatch(TbuserQO user) throws Exception {

		logger.debug("deleteBatch TbuserQO content ===>"
				+ user.inputDescription());

		int rows = userDao.delete(user);

		logger.debug("deleteBatch columns ===>" + rows);

		return rows;
	}

	@Override
	public TbuserPO selectById(String user_id) throws Exception {

		logger.debug("selectById user_id content ===>" + user_id);

		TbuserPO entity = userDao.getByPk(user_id);

		logger.debug("selectById columns ===>" + entity.inputDescription());

		return entity;
	}

	@Override
	public Page<TbuserPO> selectCondition(TbuserQO user) throws Exception {

		logger.debug("selectCondition TbuserQO content ===>"
				+ user.inputDescription());

		Page<TbuserPO> entity = userDao.find(user);

		logger.debug("selectCondition columns ===>" + entity.toString());

		return entity;
	}

	@Override
	public Page<TbuserPO> selectAll(TbuserQO user) throws Exception {

		logger.debug("selectCondition TbuserQO content ===>"
				+ user.inputDescription());

		Page<TbuserPO> entity = userDao.find(user);

		logger.debug("selectCondition columns ===>" + entity.toString());

		return entity;
	}

	@Override
	public int selectCount(TbuserQO user) throws Exception {

		logger.debug("selectCount TbuserQO content ===>"
				+ user.inputDescription());

		int rows = userDao.count(user);

		logger.debug("selectCount columns ===>" + rows);

		return rows;
	}
}
